<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>Document</title>
        <script src="lib/vue-2.6.10.js"></script>
    </head>
    <body>
        <div id="app">
            <input type="button" value="浪起来" v-on:click="lang" />
            <input type="button" value="低调" v-on:click="di" />
            <h4>{{ msg }}</h4>
        </div>

        <script>
            var app = new Vue({
                el: '#app',
                data: {
                    msg: 'Hello,Vue',
                    timer: null
                },
                methods: {
                    lang() {
                        clearInterval(this.timer);
                        this.timer = setInterval(() => {
                            // 获取文本的第一个字符
                            var start = this.msg.substring(0, 1);
                            // 获取第一个字符之后的所有字符
                            var end = this.msg.substring(1);
                            // 重新拼接得到的字符串，并赋值给this.msg
                            this.msg = end + start;
                        }, 200);
                    },
                    di() {
                        clearInterval(this.timer);
                    }
                }
            });
        </script>
    </body>
</html>
